package cn.fzkj.project.common.service.impl;

import cn.fzkj.common.ResultVO;
import cn.fzkj.common.constant.Constants;
import cn.fzkj.common.utils.BackGroundUtil;
import cn.fzkj.framework.redis.utils.RedisUtil;
import cn.fzkj.project.common.service.ICommonService;
import com.baomidou.mybatisplus.extension.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.io.Console;

@Service
@Primary
public class CommonServiceImpl implements ICommonService {
    /** 拿到配置的图片保存路径. */
    @Value(value = "${img.path}")
    private String path;
    /** 拿到python可执行文件的位置. */
    @Value(value="${img.exec-path}")
    private String execPath;
    @Autowired
    private RedisUtil redisUtil;

    @Override
    public String getImgByPy() {
        return new BackGroundUtil().getImgByPy(execPath, path);
    }

    /** 往redis中put一个图片 */
    public boolean setImg2Redis(){
        String imgPath = getImgByPy();
        return redisUtil.set(Constants.IMG_PREFIX, imgPath);
    }
}
